package 算法.LeetCode91.每日打卡题目;

import java.util.Stack;

/**
 * @author: 谢君臣
 * @create: 2021-02-04 19:37
 * @founction: XXXX
 */
public class day05 {
    public static void main(String[] args) throws InterruptedException {
    }

}
class MyQueue {
    Stack<Integer> input = new Stack<>();
    Stack<Integer> output = new Stack<>();
    /** Initialize your data structure here. */
    public MyQueue() {
        input.clear();
        output.clear();
    }

    /** Push element x to the back of queue. */
    public void push(int x) {
        input.push(x);
    }

    /** Removes the element from in front of queue and returns that element. */
    public int pop() {
        if (output.empty()){
            while (!input.empty())
                output.push(input.pop());
        }
        if (output.empty())
            return -1;
        else
            return output.pop();
    }

    /** Get the front element. */
    public int peek() {
        if (output.empty()){
            while (!input.empty())
                output.push(input.pop());
        }
        if (output.empty())
            return -1;
        else
            return output.peek();
    }

    /** Returns whether the queue is empty. */
    public boolean empty() {
        return input.empty()&&output.empty();
    }
}